
#ifndef _BSP_RS485_H_
#define _BSP_RS485_H_

#include "bsp.h"

#include "driver/uart.h"


#define ECHO_UART_PORT UART_NUM_1
#define PACKET_READ_TICS        (100 / portTICK_RATE_MS)
#define ECHO_TASK_STACK_SIZE    (2048)
#define ECHO_TASK_PRIO          (10)

#define BAUD_RATE 9600
#define BUF_SIZE        (127)


// Note: Some pins on target chip cannot be assigned for UART communication.
// Please refer to documentation for selected board and target to configure pins using Kconfig.
#define ECHO_TEST_TXD   2//(CONFIG_ECHO_UART_TXD)
#define ECHO_TEST_RXD   3//(CONFIG_ECHO_UART_RXD)

// RTS for RS485 Half-Duplex Mode manages DE/~RE
#define ECHO_TEST_RTS   19//(CONFIG_ECHO_UART_RTS)

// CTS is not used in RS485 Half-Duplex Mode
#define ECHO_TEST_CTS   19//(UART_PIN_NO_CHANGE)

// Timeout threshold for UART = number of symbols (~10 tics) with unchanged state on receive pin
#define ECHO_READ_TOUT          (3) // 3.5T * 8 = 28 ticks, TOUT=3 -> ~24..33 ticks

void bsp_rs485_init(void);

#endif
